package com.itheima.mp.controller;

import cn.hutool.core.bean.BeanUtil;
import com.itheima.mp.domain.dto.UserFormDTO;
import com.itheima.mp.domain.po.User;
import com.itheima.mp.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zyk
 * @date 2024/3/25 12:41
 * @return
 */
@Api(tags = "这是用户管理接口")
@RestController
@RequestMapping("/users")

public class UserController {

    private IUserService userService;
//    注解@ApiOperation是用来构建Api文档的
    @ApiOperation("新增用户接口")
    @PostMapping
    public void  saveUser(@RequestBody UserFormDTO userDTO){

//        1.把DTO拷贝到PO
        User user = BeanUtil.copyProperties(userDTO, User.class);
//        2.新增
        userService.save(user);



    }

}
